<template>
  <div class="container">
    <el-form ref="form" :model="listadmin" label-width="100px">
      <el-form-item label="昵称">
        <el-input v-model="listadmin.name" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="账号">
        <el-input v-model="listadmin.account" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="年龄">
        <el-input v-model="listadmin.age" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="性别" :disabled="true">
        <el-radio disabled  v-model="listadmin.gender" label="男">男</el-radio>
        <el-radio disabled  v-model="listadmin.gender" label="女">女</el-radio>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="listadmin.phone" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="账号状态">
        <el-select v-model="listadmin.status">
          <el-option label="申请中" value="0"></el-option>
          <el-option label="已通过" value="1"></el-option>
          <el-option label="未通过" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="updateSudent">点击完成</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { putadmin } from "@/api/apply";
export default {
  data() {
    return {
      listadmin: {},
    };
  },
  created() {
    // 如果是跳转来的，则接受初始化参数
    if (this.$route.query) {
      this.listadmin = this.$route.query.data;
      if (this.listadmin.status == 0) {
        this.listadmin.status = "申请中";
      }
      if (this.listadmin.status == 1) {
        this.listadmin.status = "已通过";
      }
      if (this.listadmin.status == 2) {
        this.listadmin.status = "未通过";
      }
    }
  },
  methods: {
    updateSudent() {
      console.log(this.listadmin._id, this.listadmin);
      putadmin(this.listadmin._id, this.listadmin);
      this.$router.push({ name: "informationa" });
    },
  },
};
</script>

<style scoped>
.container {
  margin: 25px auto;
  width: 800px;
}
</style>